<template>
  <el-menu router>
    <!--   根据页面路由，动态生成侧边导航栏   -->
    <el-menu-item class="my-menu-item" v-for="(item,index) in routerOptions" :key="index" :index="item.path">
      <i :class="item.icon"></i>
      <span slot="title">{{ item.name }}</span>
    </el-menu-item>
  </el-menu>
</template>

<script>
export default {
  name: "Stool",
  computed:{
    routerOptions(){
      // 计算属性，侧边栏创建时获取路由列表
      return this.$router.options.routes.find(item => {
        return item['path'] = '/';
      })['children']
    }
  }
}
</script>
